﻿using Application.AppExtensions.MiddleWare;
using Microsoft.AspNetCore.Builder;

namespace Application.AppExtensions
{
    public static class JieBaBuilderExtensions
    {
        internal const string JieBaMiddlewareSetKey = "__JieBaMiddlewareSet";

        public static IApplicationBuilder UseJieBa(this IApplicationBuilder app)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            app.Properties[JieBaMiddlewareSetKey] = true;
            return app.UseMiddleware<JieBaRequestMiddleware>();
        }
    }
}
